backup.generatePDF   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 3
rs 10
nop 2
1
var blocktrail = require('../'); // require('blocktrail-sdk') when trying example from in your own project
2
var blocktrailBackupGenerator = require('blocktrail-sdk-backup-generator');
3
var crypto = require('crypto');
4
var fs = require('fs');
5
var path = require('path');
6
7
var LIBPATH = path.normalize(__dirname + '/..');
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
8
9
var client = blocktrail.BlocktrailSDK({
10
    apiKey: "MY_APIKEY",
11
    apiSecret: "MY_APISECRET",
12
    testnet: true
13
});
14
15
var identifier = "rubensayshi";
16
var encryptedPrimarySeed = "fat arena brown skull echo quick cargo stereo welcome option pair warrior silk badge try churn note frog lemon open assault squirrel cave echo inch diagram army disease lobster version organ slow pride slush bunker blade diet bundle pair over flavor nerve name debate disease glow illness weather ";
17
var recoveryEncryptedSecret = "fat arena brown skull echo quit spring paddle nut private chronic genre prison security earth choose smooth trumpet woman depart identify recall pave van note pear because engine snow south pool relax solid language riot double denial filter palm beyond senior club illness prize ritual orange pelican eyebrow consider purse dress screen during rubber length path jealous juice display style hunt lunch nothing valve drill forum spray frequent assault range night lounge ";
18
var backupSeed = "satoshi mango during hybrid inch order expose height quantum bulb vast mansion little swift nature network pioneer fan airport symptom imitate task tooth element";
19
var encryptedSecret = "fat arena brown skull echo question sick foster december damage critic novel shed prevent wise group picture swift avoid round problem share sure chat dose pear defense remember fringe office attack speed tent nose person mammal pipe design fuel brush follow peasant defense derive pledge absent shock file gravity output search senior accuse entire awkward private crunch spoon symbol mountain inch rather butter kiss planet impulse curious border burger lake shop engine";
20
var blocktrailPublicKeys = {
21
    0: blocktrail.bitcoin.HDNode.fromSeedHex("010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"),
22
    1: blocktrail.bitcoin.HDNode.fromSeedHex("020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202"),
23
    2: blocktrail.bitcoin.HDNode.fromSeedHex("020202020202020202020203020202020202020202020203020202020202020202020203020202020202020202020203"),
24
    3: blocktrail.bitcoin.HDNode.fromSeedHex("040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404040404")
25
};
26
27
var backup = new blocktrailBackupGenerator(
0 ignored issues
show
Coding Style Best Practice introduced by
By convention, constructors like blocktrailBackupGenerator should be capitalized.
Loading history...
28
    identifier,
29
    {
30
        encryptedPrimarySeed: encryptedPrimarySeed,
31
        recoveryEncryptedSecret: recoveryEncryptedSecret,
32
        backupSeed: backupSeed,
33
        encryptedSecret: encryptedSecret,
34
        blocktrailPublicKeys: blocktrailPublicKeys
35
    },
36
    [
37
        {title: "username", value: 'testing123'},
38
        {title: "note to self", value: 'buy pizza'},
39
        {title: "Support Secret", subtitle: "this can be shared with helpdesk staff to proof ownership of backup document", value: '010101'}
40
    ]
41
);
42
43
//create a pdf
44
backup.generatePDF(LIBPATH + "/examples/my-wallet-backup.pdf", function(err, result) {
45
    console.log(err, result);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
46
});
47
48
//can also be html or an image
49
backup.generateHTML(function(err, result) {
50
    if (err) {
51
        console.log(err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
52
    }
53
54
    fs.writeFile(LIBPATH + "/examples/my-wallet-backup.html", result, function(err) {
55
        if (err) {
56
            console.log(err);
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
57
        } else {
58
            console.log("The file was saved!");
59
        }
60
    });
61
});
62